package com.grj.parkingsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.grj.parkingsystem.entity.SystemConfig;
import com.grj.parkingsystem.service.SystemConfigService;
import com.grj.parkingsystem.mapper.SystemConfigMapper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author ganru
* @description 针对表【t_system_config(系统配置表)】的数据库操作Service实现
* @createDate 2025-05-16 16:51:44
*/
@Service
public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigMapper, SystemConfig>
    implements SystemConfigService{
    @Override
    public Map<String, String> getAllConfigs() {
        List<SystemConfig> configs = list();
        Map<String, String> result = new HashMap<>();
        for (SystemConfig config : configs) {
            result.put(config.getConfigKey(), config.getConfigValue());
        }
        return result;
    }

    @Override
    public String getConfigValue(String configKey) {
        SystemConfig config = getOne(new QueryWrapper<SystemConfig>().eq("config_key", configKey));
        return config != null ? config.getConfigValue() : null;
    }

}




